﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LumenLiquid.InGame;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace LumenLiquid._3D
{
    internal static class ModelExtensionMethods
    {
        public static void DrawModel(this Model model, Matrix world)
        {
            var transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    effect.View = MainGame.Instance.Camera;
                    effect.Projection = MainGame.Instance.Projection;
                }

                mesh.Draw();
            }
        }
    }
}
